import time

from selenium import webdriver
from selenium.webdriver import TouchActions
from selenium.webdriver.common.by import By
class TestTouchaction():
    def setup(self):
        option = webdriver.ChromeOptions()
        #这个不满足w3c的标准所以加标准
        option.add_experimental_option('w3c',False)
        self.driver = webdriver.Chrome(options=option)
        self.driver.maximize_window()
        self.driver.implicitly_wait(3)
    def test_touch_actions(self):
        self.driver.get('https://www.baidu.com/')
        action = TouchActions(self.driver)
        ele = self.driver.find_element(By.ID,'kw')
        ele_bd = self.driver.find_element(By.ID,'su')
        action.tap(ele)
        ele.send_keys('最新新闻')
        action.tap(ele_bd)

        time.sleep(5)

        action.scroll_from_element(ele,0,10000)
        action.perform()
    def teardown(self):
        self.driver.quit()